package com.wf.mapper;

import com.wf.domain.ZhrjAlarmInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wf.vo.*;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author mpk16
 * @description 针对表【zhrj_alarm_info(事件表)】的数据库操作Mapper
 * @createDate 2024-08-22 18:08:24
 * @Entity com.wf.domain.ZhrjAlarmInfo
 */
public interface ZhrjAlarmInfoMapper extends BaseMapper<ZhrjAlarmInfo> {

    @Select("select count(*) as count,event_type as eventType from zhrj_alarm_info group by event_type")
    List<EventTypeCountVO> getCountByEventType();

    @Select("select count(*) as count,dept_id as deptId from zhrj_alarm_info group by dept_id")
    List<deptIdCountVO> getCountByDeptId();


    @Select({
            "<script>",
            "SELECT date(event_time) AS event_date, COUNT(*) AS count",
            "FROM zhrj_alarm_info",
            "WHERE event_time LIKE CONCAT(#{date}, '%')",
            "GROUP BY date(event_time)",
            "</script>"
    })
    List<DayCountVO> monthDayCount(String date);

    @Select({
            "SELECT zd.dept_name, zm.menu_name, zm.display_value, zm.menu_description",
            "FROM (",
            "    SELECT DISTINCT dept_id, event_type",
            "    FROM zhrj_alarm_info zai",
            ") zai",
            "LEFT JOIN zhrj_dept zd ON zai.dept_id = zd.dept_id",
            "LEFT JOIN zhrj_menu zm ON zai.event_type = zm.actual_value"
    })
    List<AlarmInfoVO> multipleTables();
}




